#!/bin/sh

ip=$NODE_IP
if [ -z $ip ]
then
  # if ip is empty, extract the IP associated with fly-local-6pn from /etc/hosts
  # "cut -f 1" gets the first field (separated by spaces/tabs) from each line
  ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
  # if ip is still empty (means fly-local-6pn was not found in /etc/hosts)
  if [ -z $ip ]
  then
    ip=$(hostname -f)
  fi
fi

# assign the value of NODE_NAME if it exists, else assign the value of FLY_APP_NAME,
# and if that doesn't exist either, assign "supavisor" to node_name
node_name="${NODE_NAME:=${FLY_APP_NAME:=supavisor}}"

export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=$node_name@$ip
